package com.itheima.mapper;

import com.github.pagehelper.Page;
import com.itheima.dto.OrderPageQueryDTO;
import com.itheima.pojo.Order;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface OrderMapper {
    /**
     * 分页查询
     * @param orderPageQueryDTO
     * @return
     */
    Page<Order> pageQuery(OrderPageQueryDTO orderPageQueryDTO);

    /**
     *
     * @param order
     */
    void updateOrder(Order order);

    /**
     * 今日预约数
     */
    @Select("select count(id) from orders where to_days(orderDate)= to_days(curdate())")
    Integer findTodayOrderNumber();

    /**
     * 今日到诊数
     * @param orderstatusYes
     * @return
     */
    @Select("select count(id) from orders where to_days(orderDate)= to_days(curdate()) and orderStatus=#{orderstatusYes}")
    Integer findTodayVisitsNumber(String orderstatusYes);

    /**
     * 本周预约数
     * @return
     */
    @Select("select count(id) from orders where yearweek(orderDate,1) = yearweek(now(),1)")
    Integer findThisWeekOrderNumber();

    /**
     * 本周到诊数
     * @return
     */
    @Select("select count(id) from orders where yearweek(orderDate,1) = yearweek(now(),1) and orderStatus=#{orderstatusYes}")
    Integer findThisWeekVisitsNumber(String orderstatusYes);

    /**
     * 本月预约数
     */
    @Select("select count(id) from orders where date_format(orderDate,'%Y%m')=date_format(curdate(),'%Y%m')")
    Integer findThisMonthOrderNumber();

    /**
     * 本月到诊数
     * @param orderstatusYes
     */
    @Select("select count(id) from orders where date_format(orderDate,'%Y%m')=date_format(curdate(),'%Y%m')and orderStatus=#{orderstatusYes}")
    Integer findThisMonthVisitsNumber(String orderstatusYes);
}
